package com.web.dao.impl;

import com.web.dao.UserDAO;
import com.web.entity.User;
import com.web.util.JDBCUtils;

import java.util.List;

public class UserDAOimpl implements UserDAO {
    @Override
    public User selectByUsername(String username) {
        List<User> users = JDBCUtils.query(User.class,
                "select * from t_user where username=?", username);
        if (users.size() > 0){
            return users.get(0);
        }
        return null;
    }

    @Override
    public void updateUser(User user) {
        JDBCUtils.update("update t_user set nickname=?,icon=?,email=? where id=?",
                user.getNickname(), user.getIcon(), user.getEmail(), user.getId());
    }
}
